package com.java.tutorials.spring;

import org.junit.Test;
import org.springframework.context.MessageSource;

import java.util.Locale;

/**
 * 测试resource bundle
 */
public class ResourceBundleTest extends SpringTesterBase {
    @Test
    public void printMessageFromProperties(){
        MessageSource  source =(MessageSource) ctx.getBean("staticMessageSource");
        //不带参数
        String name = source.getMessage("user.name",null, Locale.CHINA);
        System.out.println("name="+name);

        //带有参数
        String message = source.getMessage("argument.required",
                new Object [] {"userDao"}, "Required", null);
        System.out.println("带参数 argument.required="+message);

        //①直接通过容器访问国际化信息
        message = ctx.getMessage("argument.required",
                new Object [] {"容器级"}, "Required", null);
        System.out.println("容器级别 argument.required="+message);
    }
}
